package io.noties.markwon.plugin.latex.parser

import com.gitee.wsl.common.commonmark.inline.AbstractMatchInlineParser
import io.noties.markwon.plugin.latex.model.JLatexMathNode
import java.util.regex.Pattern

/**
 * @since 4.3.0
 */
internal class JLatexMathInlineProcessor : AbstractMatchInlineParser<JLatexMathNode>() {

   /* protected Node parse() {
        final String latex = match(RE);
        if (latex == null) {
            return null;
        }

        final JLatexMathNode node = new JLatexMathNode();
        node.latex(latex.substring(2, latex.length() - 2));
        return node;
    }*/

    companion object {
        private val RE = Pattern.compile("(\\\${2})([\\s\\S]+?)\\1")
    }

    override fun specialCharacter(): Char = '$'

    override fun getPattern(): Pattern = RE

    override fun createNode(text: String): JLatexMathNode = JLatexMathNode(text.substring(2, text.length - 2))

}

